gdk: Remove motion hints
authorCarlos Garnacho <carlosg@gnome.org>
Fri, 15 Sep 2017 16:58:50 +0000 (18:58 +0200)
committerCarlos Garnacho <carlosg@gnome.org>
Tue, 19 Sep 2017 16:40:51 +0000 (18:40 +0200)
Motion hints are now literally a thing of the past. Everything should be
using the full motion event stream.

13 files changed:
gdk/gdkdevice.c
gdk/gdkdisplay.c
gdk/gdkdisplayprivate.h
gdk/gdkevents.c
gdk/gdktypes.h
gdk/gdkwindow.c
gdk/x11/gdkdevice-core-x11.c
gdk/x11/gdkdevice-xi2.c
gdk/x11/gdkdevicemanager-xi2.c
gtk/gtkaboutdialog.c
gtk/gtkgesture.c
gtk/gtktooltip.c
gtk/gtkwidget.c

index 9c84e0ca428dde7e6e6e0290b51af8b4c94ad639..fd918f374b3f7f8bc6cdfce8ce178a42c14077f0 100644 (file)
@@ -1378,8 +1378,7 @@ get_native_grab_event_mask (GdkEventMask grab_mask)
     GDK_ENTER_NOTIFY_MASK | GDK_LEAVE_NOTIFY_MASK |
     GDK_SCROLL_MASK |
     (grab_mask &
-     ~(GDK_POINTER_MOTION_HINT_MASK |
-       GDK_BUTTON_MOTION_MASK |
+     ~(GDK_BUTTON_MOTION_MASK |
        GDK_BUTTON1_MOTION_MASK |
        GDK_BUTTON2_MOTION_MASK |
        GDK_BUTTON3_MOTION_MASK));
index a4a75bc2fb27dd70393e02663e561b92512d8322..b0d30b57dc25b1367c8b980d2eb3a26bca347aac 100644 (file)
@@ -379,8 +379,6 @@ gdk_display_init (GdkDisplay *display)
 
   display->touch_implicit_grabs = g_array_new (FALSE, FALSE, sizeof (GdkTouchGrabInfo));
   display->device_grabs = g_hash_table_new (NULL, NULL);
-  display->motion_hint_info = g_hash_table_new_full (NULL, NULL, NULL,
-                                                     (GDestroyNotify) g_free);
 
   display->pointers_info = g_hash_table_new_full (NULL, NULL, NULL,
                                                   (GDestroyNotify) free_pointer_info);
@@ -433,7 +431,6 @@ gdk_display_finalize (GObject *object)
 
   g_array_free (display->touch_implicit_grabs, TRUE);
 
-  g_hash_table_destroy (display->motion_hint_info);
   g_hash_table_destroy (display->pointers_info);
 
   g_list_free_full (display->input_devices, g_object_unref);
@@ -605,35 +602,6 @@ gdk_flush (void)
   g_slist_free (list);
 }
 
-void
-_gdk_display_enable_motion_hints (GdkDisplay *display,
-                                  GdkDevice  *device)
-{
-  gulong *device_serial, serial;
-
-  device_serial = g_hash_table_lookup (display->motion_hint_info, device);
-
-  if (!device_serial)
-    {
-      device_serial = g_new0 (gulong, 1);
-      *device_serial = G_MAXULONG;
-      g_hash_table_insert (display->motion_hint_info, device, device_serial);
-    }
-
-  if (*device_serial != 0)
-    {
-      serial = _gdk_display_get_next_serial (display);
-      /* We might not actually generate the next request, so
-        make sure this triggers always, this may cause it to
-        trigger slightly too early, but this is just a hint
-        anyway. */
-      if (serial > 0)
-       serial--;
-      if (serial < *device_serial)
-       *device_serial = serial;
-    }
-}
-
 static void
 generate_grab_broken_event (GdkDisplay *display,
                             GdkWindow  *window,
index 8c37ed6d2222c289a32327480aec14ce7717827c..fe6ea0f001a9b9c915071ab5ccba2686fae9370c 100644 (file)
@@ -99,7 +99,6 @@ struct _GdkDisplay
 
   GArray *touch_implicit_grabs;
   GHashTable *device_grabs;
-  GHashTable *motion_hint_info;
   GdkDeviceManager *device_manager;
   GList *input_devices; /* Deprecated, only used to keep gdk_display_list_devices working */
 
@@ -298,8 +297,6 @@ GdkTouchGrabInfo *  _gdk_display_has_touch_grab       (GdkDisplay       *display
 gboolean            _gdk_display_end_touch_grab       (GdkDisplay       *display,
                                                        GdkDevice        *device,
                                                        GdkEventSequence *sequence);
-void                _gdk_display_enable_motion_hints  (GdkDisplay       *display,
-                                                       GdkDevice        *device);
 GdkPointerWindowInfo * _gdk_display_get_pointer_info  (GdkDisplay       *display,
                                                        GdkDevice        *device);
 void                _gdk_display_pointer_info_foreach (GdkDisplay       *display,
index 044b3f0635121c95f7dc49d8ceea396cf9f8f68f..9904e5bdbeb8c15c0c17223198cd7b2730a99c45 100644 (file)
@@ -1860,46 +1860,6 @@ gdk_event_get_source_device (const GdkEvent *event)
   return gdk_event_get_device (event);
 }
 
-/**
- * gdk_event_request_motions:
- * @event: a valid #GdkEvent
- *
- * Request more motion notifies if @event is a motion notify hint event.
- *
- * This function should be used instead of gdk_window_get_pointer() to
- * request further motion notifies, because it also works for extension
- * events where motion notifies are provided for devices other than the
- * core pointer. Coordinate extraction, processing and requesting more
- * motion events from a %GDK_MOTION_NOTIFY event usually works like this:
- *
- * |[<!-- language="C" -->
- * {
- *   // motion_event handler
- *   x = motion_event->x;
- *   y = motion_event->y;
- *   // handle (x,y) motion
- *   gdk_event_request_motions (motion_event); // handles is_hint events
- * }
- * ]|
- *
- * Since: 2.12
- **/
-void
-gdk_event_request_motions (const GdkEventMotion *event)
-{
-  GdkDisplay *display;
-  
-  g_return_if_fail (event != NULL);
-  
-  if (event->type == GDK_MOTION_NOTIFY && event->is_hint)
-    {
-      gdk_device_get_state (event->device, event->window, NULL, NULL);
-      
-      display = gdk_window_get_display (event->window);
-      _gdk_display_enable_motion_hints (display, event->device);
-    }
-}
-
 /**
  * gdk_event_triggers_context_menu:
  * @event: a #GdkEvent, currently only button events are meaningful values
index 73bf2feccd38134bf2d4fe4fcba201d67773a794..20f759f33f53bd4965fadb77def1d40c49de912c 100644 (file)
@@ -373,7 +373,6 @@ typedef enum
  * GdkEventMask:
  * @GDK_EXPOSURE_MASK: receive expose events
  * @GDK_POINTER_MOTION_MASK: receive all pointer motion events
- * @GDK_POINTER_MOTION_HINT_MASK: deprecated. see the explanation above
  * @GDK_BUTTON_MOTION_MASK: receive pointer motion events while any button is pressed
  * @GDK_BUTTON1_MOTION_MASK: receive pointer motion events while 1 button is pressed
  * @GDK_BUTTON2_MOTION_MASK: receive pointer motion events while 2 button is pressed
@@ -406,14 +405,6 @@ typedef enum
  * See the [input handling overview][chap-input-handling] for details of
  * [event masks][event-masks] and [event propagation][event-propagation].
  *
- * %GDK_POINTER_MOTION_HINT_MASK is deprecated. It is a special mask
- * to reduce the number of %GDK_MOTION_NOTIFY events received. When using
- * %GDK_POINTER_MOTION_HINT_MASK, fewer %GDK_MOTION_NOTIFY events will
- * be sent, some of which are marked as a hint (the is_hint member is
- * %TRUE). To receive more motion events after a motion hint event,
- * the application needs to asks for more, by calling
- * gdk_event_request_motions().
- * 
  * Since GTK 3.8, motion events are already compressed by default, independent
  * of this mechanism. This compression can be disabled with
  * gdk_window_set_event_compression(). See the documentation of that function
@@ -430,7 +421,6 @@ typedef enum
 {
   GDK_EXPOSURE_MASK             = 1 << 1,
   GDK_POINTER_MOTION_MASK       = 1 << 2,
-  GDK_POINTER_MOTION_HINT_MASK  = 1 << 3,
   GDK_BUTTON_MOTION_MASK        = 1 << 4,
   GDK_BUTTON1_MOTION_MASK       = 1 << 5,
   GDK_BUTTON2_MOTION_MASK       = 1 << 6,
index 14bea5aa3d032f4c504be27e1875e0a7e8575835..3daf7d63c9d4b61c6f38dd4b46a38f4bddd55298 100644 (file)
@@ -948,14 +948,7 @@ get_native_device_event_mask (GdkWindow *private,
     {
       GdkEventMask mask;
 
-      /* Do whatever the app asks to, since the app
-       * may be asking for weird things for native windows,
-       * but don't use motion hints as that may affect non-native
-       * child windows that don't want it. Also, we need to
-       * set all the app-specified masks since they will be picked
-       * up by any implicit grabs (i.e. if they were not set as
-       * native we would not get the events we need). */
-      mask = private->event_mask & ~GDK_POINTER_MOTION_HINT_MASK;
+      mask = private->event_mask;
 
       /* We need thse for all native windows so we can
         emulate events on children: */
@@ -3397,8 +3390,6 @@ gdk_window_get_device_position_double (GdkWindow       *window,
   if (mask)
     *mask = tmp_mask;
 
-  _gdk_display_enable_motion_hints (gdk_window_get_display (window), device);
-
   if (normal_child)
     return _gdk_window_find_child_at (window, tmp_x, tmp_y);
   return NULL;
@@ -3953,27 +3944,12 @@ gdk_window_set_events (GdkWindow       *window,
                       GdkEventMask     event_mask)
 {
   GdkWindowImplClass *impl_class;
-  GdkDisplay *display;
 
   g_return_if_fail (GDK_IS_WINDOW (window));
 
   if (window->destroyed)
     return;
 
-  /* If motion hint is disabled, enable motion events again */
-  display = gdk_window_get_display (window);
-  if ((window->event_mask & GDK_POINTER_MOTION_HINT_MASK) &&
-      !(event_mask & GDK_POINTER_MOTION_HINT_MASK))
-    {
-      GList *devices = window->devices_inside;
-
-      while (devices)
-        {
-          _gdk_display_enable_motion_hints (display, (GdkDevice *) devices->data);
-          devices = devices->next;
-        }
-    }
-
   window->event_mask = event_mask;
 
   if (gdk_window_has_impl (window))
@@ -4027,7 +4003,6 @@ gdk_window_set_device_events (GdkWindow    *window,
                               GdkEventMask  event_mask)
 {
   GdkEventMask device_mask;
-  GdkDisplay *display;
   GdkWindow *native;
 
   g_return_if_fail (GDK_IS_WINDOW (window));
@@ -4036,12 +4011,6 @@ gdk_window_set_device_events (GdkWindow    *window,
   if (GDK_WINDOW_DESTROYED (window))
     return;
 
-  /* If motion hint is disabled, enable motion events again */
-  display = gdk_window_get_display (window);
-  if ((window->event_mask & GDK_POINTER_MOTION_HINT_MASK) &&
-      !(event_mask & GDK_POINTER_MOTION_HINT_MASK))
-    _gdk_display_enable_motion_hints (display, device);
-
   if (G_UNLIKELY (!window->device_events))
     window->device_events = g_hash_table_new (NULL, NULL);
 
@@ -5777,8 +5746,6 @@ _gdk_display_set_window_under_pointer (GdkDisplay *display,
       g_object_ref (window);
       update_cursor (display, device);
     }
-
-  _gdk_display_enable_motion_hints (display, device);
 }
 
 static void
index e0d34ed32956d4cf1a46aba9b295cd817a464050..418546c63856cfc36f8cf12d328703f502adff49 100644 (file)
@@ -571,7 +571,6 @@ gdk_x11_device_core_select_window_events (GdkDevice    *device,
 
   window_mask = gdk_window_get_events (window);
   filter_mask = GDK_POINTER_MOTION_MASK
-                | GDK_POINTER_MOTION_HINT_MASK
                 | GDK_BUTTON_MOTION_MASK
                 | GDK_BUTTON1_MOTION_MASK
                 | GDK_BUTTON2_MOTION_MASK
index 23857a5ca9c89bb06012be745c8e82f9b79a4f70..bdf28c4b0f8ed201b7193449182382ab4d3dba03 100644 (file)
@@ -709,8 +709,7 @@ _gdk_x11_device_xi2_translate_event_mask (GdkX11DeviceManagerXI2 *device_manager
   *len = XIMaskLen (XI_LASTEVENT);
   mask = g_new0 (guchar, *len);
 
-  if (event_mask & GDK_POINTER_MOTION_MASK ||
-      event_mask & GDK_POINTER_MOTION_HINT_MASK)
+  if (event_mask & GDK_POINTER_MOTION_MASK)
     XISetMask (mask, XI_Motion);
 
   if (event_mask & GDK_BUTTON_MOTION_MASK ||
index 787da0cb3a30c1240c43831bb19d6b4fa1a5e6eb..41d5faeafbc842f430f0031b485111ff579f7471 100644 (file)
@@ -1979,7 +1979,6 @@ gdk_x11_device_manager_xi2_get_handled_events (GdkEventTranslator *translator)
           GDK_ENTER_NOTIFY_MASK |
           GDK_LEAVE_NOTIFY_MASK |
           GDK_POINTER_MOTION_MASK |
-          GDK_POINTER_MOTION_HINT_MASK |
           GDK_BUTTON1_MOTION_MASK |
           GDK_BUTTON2_MOTION_MASK |
           GDK_BUTTON3_MOTION_MASK |
index c4c95eeb9826f42010015c84e840a7426efccf61..23482c675734fdf10bc17795f8fb363f1be1f6e4 100644 (file)
@@ -2134,8 +2134,6 @@ text_view_motion_notify_event (GtkWidget      *text_view,
   set_cursor_if_appropriate (about, GTK_TEXT_VIEW (text_view),
                              gdk_event_get_device ((GdkEvent *) event), x, y);
 
-  gdk_event_request_motions (event);
-
   return FALSE;
 }
 
index d170fd067bf724b4eee672411cb14891b43f68fc..67d91535daf6e527ed3292837f1fe372594f5acd 100644 (file)
@@ -722,8 +722,6 @@ gtk_gesture_handle_event (GtkEventController *controller,
         {
           if ((state & BUTTONS_MASK) == 0)
             return FALSE;
-
-          gdk_event_request_motions ((GdkEventMotion *)event);
         }
 
       if (_gtk_gesture_update_point (gesture, event, FALSE) &&
index 063bedd49693bd1c08df06e55b52f76b3c40848f..7fab3c8b6fbf8b7dc1bac5f80e1b59c4e5f377d1 100644 (file)
@@ -1393,10 +1393,6 @@ _gtk_tooltip_handle_event (GdkEvent *event)
   gdk_event_get_coords (event, &dx, &dy);
 
   gtk_tooltip_handle_event_internal (event_type, window, dx, dy);
-
-  /* Always poll for a next motion event */
-  gdk_event_request_motions ((GdkEventMotion *) event);
-
 }
 
 static void
index 262ac8003922aec8983babeb01cf01e67ce00c2b..62ae353ab98d63b9421c7a63185a79734f951432 100644 (file)
@@ -6675,17 +6675,6 @@ _gtk_widget_captured_event (GtkWidget      *widget,
   return_val |= handler (widget, event_copy);
   return_val |= !WIDGET_REALIZED_FOR_EVENT (widget, event_copy);
 
-  /* The widget that was originally to receive the event
-   * handles motion hints, but the capturing widget might
-   * not, so ensure we get further motion events.
-   */
-  if (return_val &&
-      event_copy->type == GDK_MOTION_NOTIFY &&
-      event_copy->motion.is_hint &&
-      (gdk_window_get_events (event_copy->any.window) &
-       GDK_POINTER_MOTION_HINT_MASK) != 0)
-    gdk_event_request_motions (&event_copy->motion);
-
   g_object_unref (widget);
 
 out: